#!/usr/bin/python
# -*- coding:UTF8 -*-

# 文件写入
# 生成100个测试用户，test1-test100 保存文件中
# 生成100个用户
import pandas as pd

for i in range(10):
    user = 'test' + str(i + 1)
    print(user)
    data = pd.DataFrame([user])
    data.to_csv('./testdata.csv', mode='a',header=0,index=0)
    # with open('./testdata.csv', 'r') as file:
    #     print(file.read())

# while 循环
# 当不确定循环次数时， 使用 while 循环。
import random

while True:
    password = int(random.random() * 1000)
    print(password)
    if password > 900:
        break

# if 语句
# and和or
if 10 < 9 and int('abc') > 10:
    print("yes")
else:
    print('no')

# if 10 > 9 and int('abc') > 10:
#     print("yes")
# else:
#     print('no')

if 10 > 9 or int('abc') > 10:
    print("yes")
else:
    print('no')

# while循环
num = 10
while True:
    codding = int(input("请输入数字："))
    # num = num + 1
    if codding < num:
        print("小于")
    elif codding > num:
        print('大于')
    else:
        print("刚刚好")
        break

num = 0
while True:
    print('helloworld')
    num = num + 1
    if num == 10:
        break

"""
设计一个 ATM 取款流程，默认密码为 888888 提示用户输入密码
密码输入正确进入系统
输入错误，提示重新输入密码
如果错误次数超过3次，退出程序，提示用户已经超过最大次数。

"""
password = 888888
num = 0
while True:
    codding = int(input("请输入密码："))
    num = num + 1
    if codding == password:
        print("输入正确进入系统")
        break
    elif num < 3:
        print('密码错误，请重新输入')
    else:
        print("输入错误次数过多，密码已锁死，请至柜台处理")
        break

for i in range(100):
    print(i)
    if i > 9:
        break

for i in range(1, 10):
    # print(i)
    if i % 2 == 0:
        print(f"{i}是偶数")
        continue
    else:
        print(f"{i}是奇数")
# for .... else ....
# 当for 循环执行完成之后，会执行else 中的代码
for i in range(1, 10):
    print(i)
else:
    print('helloworld')

# 模拟银行ATM机中 密码输入问题:频次
password = 888888
# num = 0
# while True:
for freq in range(1, 4):
    codding = int(input("请输入密码："))
    # num = num + 1
    if codding == password:
        print("输入正确进入系统")
        break
    elif num < 3:
        print('密码错误，请重新输入')
else:
    print("输入错误次数过多，密码已锁死，请至柜台处理")
    # break
